﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class BattleSettings : Singleton<BattleSettings>
{
    public static bool s_bTestTroopNum = false;
    public static int s_troopNum = 1;

    public static bool s_bShowHero = true;
    public static bool s_bMoveCamera = false;

    public const string _batman = "batman";
    public const string _shooter = "shooter";
    public const string _knight = "knight";
    public const string _ogre = "ogre";
    public const string _naga = "naga";
    public const string _ghost = "ghost";
    public const string _archangel = "archangel";
    public const string _tank = "tank";
    public const string _mammoth = "mammoth";
    public const string _titans = "titans";
    public const string _phoenix = "phoenix";
    public const string _dragon = "dragon";

    public const string _unitActionIdle = "idle";//待机
    public const string _unitActionWalk = "walk";//行走
    public const string _unitActionRun = "run";//奔跑
    public const string _unitActionA1 = "a1";//进程攻击
    public const string _unitActionA2 = "a2";//远程攻击
    public const string _unitActionA3 = "a3";//
    public const string _unitActionS1 = "s1";//施法
    public const string _unitActionDie = "die";//死亡
    public const string _unitActionHurt = "hurt";//受伤

    //英雄的动作
    public const string _heroActionIdle = "idle";
    public const string _heroActionA1 = "a1";
    public const string _heroActionS1 = "s1";
    public const string _heroActionHurt = "hurt";
    public const string _heroActionDie = "die";

    //红 蓝 材质球前缀
    public const string MatRed = "_red";
    public const string MatBlue = "_blue";

    //武将预设路径   之后看配在哪里
    public static Dictionary<int, string> sHeroResPath = new Dictionary<int, string>()
    {
        {1,"Battle/Hero/hero1" },
        {2,"Battle/Hero/hero2" },
        {3,"Battle/Hero/hero3" },
        {4,"Battle/Hero/hero1" },
        {5,"Battle/Hero/hero2" },
        {6,"Battle/Hero/hero3" },
    };


    //武将类型前缀
    public static Dictionary<int, string> sHeroType = new Dictionary<int, string>()
    {
        {1,_batman },
        {2,_shooter },
        {3,_knight},
        {4,_batman},
        {5,_shooter },
        {6,_knight },
    };


    public List<int> _xOffsetNodeList = new List<int>();
    public List<int> _zOffsetNodeList = new List<int>();
    public List<string> _paperModelUnitBaseActionList = new List<string>();
    public Dictionary<string, PhysicData> _physicDataDic = new Dictionary<string, PhysicData>();

    public Dictionary<string, float> _unitTypeHurtTimeDic = new Dictionary<string, float>();

    public const string _attackPat_Melee = "melee";
    public const string _attackPat_Remote = "remote";
    public const string _attackPat_Spec = "special";
    public const string _attackPat_Rush = "Rush";

    public static float _bigUnitOffsetLength = 2.9694f;
    public static float _mediumUnitOffsetLength = 1.6968f;
    public static float _smallUnitOffsetLength =2.121f ;

    public void Init()
    {
        InitNewTroopInitialPosOffset();
        InitPaperUnitActionList();
        InitPhysicData();
    }

    public void InitHurtTimeDic()
    {
        _unitTypeHurtTimeDic[_titans] = 1.067f;
        _unitTypeHurtTimeDic[_phoenix] = 1.067f;
        _unitTypeHurtTimeDic[_dragon] = 1.067f;
    }


    private void InitNewTroopInitialPosOffset()
    {
        _xOffsetNodeList.Add(82);
        _xOffsetNodeList.Add(33);
        _xOffsetNodeList.Add(131);

        _zOffsetNodeList.Add(32);
        _zOffsetNodeList.Add(65);
        _zOffsetNodeList.Add(98);
        _zOffsetNodeList.Add(125);
        _zOffsetNodeList.Add(158);
        _zOffsetNodeList.Add(191);
    }

    private void InitPaperUnitActionList()
    {
        _paperModelUnitBaseActionList.Add("idle");
        _paperModelUnitBaseActionList.Add("walk");
        _paperModelUnitBaseActionList.Add("run");
        _paperModelUnitBaseActionList.Add("a1");
        _paperModelUnitBaseActionList.Add("a2");
        _paperModelUnitBaseActionList.Add("s1");
        _paperModelUnitBaseActionList.Add("die");
    }

    public void InitPhysicData()
    {
        AddPhySicDataToDic(BattleSettings._batman, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._knight, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._shooter, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._ogre, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._ghost, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._naga, 0.5f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._archangel, 1f, 0.85f, 0.2f,0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._mammoth, 1f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._tank, 1f, 0.85f, 0.2f, 0.5f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._titans, 4f, 0.85f, 0.2f, 0.85f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._dragon, 3.5f, 0.85f, 0.2f, 0f, 0.3f, 0.3f);
        AddPhySicDataToDic(BattleSettings._phoenix, 5f, 0.85f, 0.2f, 0f, 0.3f, 0.3f);
    }

    /// <summary>
    /// 添加力的信息
    /// </summary>
    /// <param name="unitType">兵种类型</param>
    /// <param name="radius">碰撞半径</param>
    /// <param name="atten">衰减系数</param>
    /// <param name="strength">力量</param>
    /// <param name="pushStrength">推力</param>
    /// <param name="colliTime">弹力时间</param>
    /// <param name="pushTime">推力时间</param>
    public void AddPhySicDataToDic(string unitType, float radius, float atten, float strength, float pushStrength, float colliTime, float pushTime)
    {
        PhysicData pd = new PhysicData();
        pd._strName = unitType;
        pd._radius = radius;
        pd._atten = atten;
        pd._strength = strength;
        pd._pushStrength = pushStrength;
        pd._colliTime = colliTime;
        pd._pushTime = pushTime;
        if (!_physicDataDic.ContainsKey(pd._strName))
        {
            _physicDataDic.Add(pd._strName, pd);
        }
    }
}

public class PhysicData
{
    // 物理体名称
    public string _strName;
    // 碰撞半径
    public float _radius = 0.5f;
    // 削弱系数
    public float _atten = 0.85f;
    // 力量
    public float _strength = 0.2f;
    // 推力
    public float _pushStrength = 8.5f;
    // 弹力时间
    public float _colliTime = 0.3f;
    // 推力时间
    public float _pushTime = 0.3f;
}